<template>
	<view class="work-container">
		<work-header @onSelect="onSelectBar"></work-header>
		<view class="work-content">
			<hot-them v-if="this.type == '0'"></hot-them>
			<theme v-else-if="this.type == '1'"></theme>
			<circle-model v-else-if="this.type == '2'"></circle-model>
		</view>
		<uni-fab ref="fab" @trigger="trigger" :pattern="pattern" :horizontal="horizontal" :vertical="vertical"
			:content="content" @fabClick="fanHandle" />
	</view>
</template>

<script>
	import hotThem from "./hotThem/index"
	import theme from "./theme/index"
	import circleModel from "./circle/index"
	export default {
		data() {
			return {
				type: "0",
				activeId: "",
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff'
				},
				direction: 'horizontal',
				horizontal: 'right',
				vertical: 'bottom',
				content: [{
					iconPath: '/static/images/tabbar/work.png',
					selectedIconPath: '/static/image-active.png',
					url: '/pages/work/add/motif',
					text: '发表主题',
					active: false
				}]
			}
		},
		components: {
			hotThem,
			theme,
			circleModel
		},
		methods: {
			onSelectBar(data) {
				this.type = data;
			},
			handleClick(item) {
				if (this.type == "2") {
					this.$tab.navigateTo(`/pages/work/circleDetails?themeId=` + item.id)
				} else {
					this.$tab.navigateTo(`/pages/work/topicdetails?themeId=` + item.id)
				}
			},
			trigger(e) {
				this.$tab.navigateTo(e.item.url);
			},
			fanHandle() {
				if (this.$store.state.user.roles) {
					if (this.content.length <= 1) {
						this.content.push({
							iconPath: '/static/images/tabbar/home.png',
							selectedIconPath: '/static/home-active.png',
							url: '/pages/work/add/circle',
							text: '管理圈子',
							active: false
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #ddd;
	}

	.work-container {
		.option-btn {
			position: fixed;
			right: 2vw;
			bottom: 10vh;
		}
	}
</style>